package com.lidong;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@RestController
public class SpringcloudsoftServiceSayApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringcloudsoftServiceSayApplication.class, args);
	}

	private static final Logger LOGGER = LoggerFactory.getLogger(SpringcloudsoftServiceSayApplication.class);

	@Autowired
    private RestTemplate restTemplate;

    @Bean
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }

	@RequestMapping("/say")
	public String say() {
		LOGGER.info("Calling trace service-say");
		return restTemplate.getForObject("http://localhost:8103/info", String.class);
	}

	@RequestMapping("/info")
	public String info() {
		LOGGER.info("Calling trace service-say");
		return "I'm service-say!!!";
	}

}
